using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Deepcode.Flux.Core.UI.Controls
{
	/// <summary>
	/// Simply creates a div with padding based on the class being used.
	/// The default class is "pad10" - specify a different one (eg pad5) with 
	/// the CssClass property.
	/// </summary>
	[ParseChildren(false)]
	public class PadBox : Deepcode.Flux.Core.UI.Controls.Base.BaseControl
	{
		/// <summary>
		/// Init - default the cssclass to pad10 and ensure common stylesheets are included
		/// </summary>
		/// <param name="e"></param>
		protected override void OnInit(EventArgs e)
		{
			base.OnInit (e);
			if( CssClass == String.Empty ) CssClass = "pad10";

			this.LoadClientStyleSheet("PadBox/PadBox.css", "Deepcode.Core.Flux.UI.Controls.PadBox");
		}
		public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
		{
			//writer.Write("<div class='{0}'>", this.CssClass);
			writer.Write("<table cellspacing='0' border='0' cellpadding='0' width='100%'><tr><td class='{0}'>", this.CssClass);
		}
		public override void RenderEndTag(System.Web.UI.HtmlTextWriter writer)
		{
			//writer.Write("</div>");
			writer.Write("</td></tr></table>");
		}
	}
}
